package cn.stdlib;

/**
 * **********************************************************************
 * Compilation:  javac Copy.java
 * Execution:    java Copy < file
 * Dependencies: BinaryStdIn.java BinaryStdOut.java
 * <p/>
 * Reads in a binary file from standard input and writes it to standard output.
 * <p/>
 * % java Copy < mandrill.jpg > copy.jpg
 * <p/>
 * %  diff mandrill.jpg copy.jpg
 * <p/>
 * ***********************************************************************
 */

public class Copy {

    public static void main(String[] args) {
        while (!BinaryStdIn.isEmpty()) {
            char c = BinaryStdIn.readChar();
            BinaryStdOut.write(c);
        }
        BinaryStdOut.flush();
    }
}
